<template>
  <div class="container">
    <el-table
      :data="tableData"
      style="width: 100%; border: 1px solid red"
      height="250"
      @row-click="itemClick"
    >
      <el-table-column fixed prop="id" label="商品编号" width="120">
      </el-table-column>
      <el-table-column prop="name" label="名称" width="120"> </el-table-column>
      <el-table-column prop="province" label="省份" width="120">
      </el-table-column>
      <el-table-column prop="city" label="市" width="120"> </el-table-column>
      <el-table-column prop="county" label="区" width="120"> </el-table-column>
      <el-table-column prop="description" label="描述" width="200">
      </el-table-column>
      <el-table-column prop="remain" label="余量" width="120">
      </el-table-column>
      <el-table-column prop="price" label="价格" width="120"> </el-table-column>
      <el-table-column prop="saleNumber" label="已卖出" width="120">
      </el-table-column>
      <el-table-column prop="createTime" label="发布时间" width="200">
      </el-table-column>
    </el-table>
    <el-dialog :visible.sync="isShow">
      <img width="100%" :src="selectImage" alt="" />
    </el-dialog>
  </div>
</template>


<script>
export default {
  data() {
    return {
      tableData: [],
      isShow: false,
      selectImage: "",
    };
  },
  methods: {
    itemClick(row) {
        this.isShow = true
        this.selectImage = row.path
    },
  },
  created() {
    this.$http({
      url: "/product/getProductList",
      method: "get",
    }).then((res) => {
      if (res.length == 0) {
        this.$message.error("请先发布一个商品");
      } else {
        this.tableData = res;
      }
    });
  },
};
</script>


<style scoped>
</style>